﻿CREATE FUNCTION [dbo].[fn_TableHasIdentityColumn]
(
	@Table sysname
)
RETURNS BIT
AS
BEGIN
	DECLARE @True  BIT; SET @True  = 1
	DECLARE @False BIT; SET @False = 0
	
	IF EXISTS (
	       SELECT *
	       FROM   sys.tables t
	              INNER JOIN sys.[columns] c
	                   ON  c.[object_id] = t.[object_id]
	       WHERE  t.[name] = @Table
                  AND t.[type] = 'U'
	              AND c.is_identity = 1
	   )
	    RETURN @True
	
	RETURN @False
END